#ifndef DEF_ENGINE_H
#define DEF_ENGINE_H

#include "../game.h"
#include "misc.h"
#include "engine_event.h"

class engine
{
   public:

      engine(game *gp) { parent = gp; }
      virtual ~engine() {}

      void push_event(engine_event& e)
      {
         events_queue.push(e);
      }

      void process_queue()
      {
         while(!events_queue.empty())
         {
            engine_event e = events_queue.front();
            events_queue.pop();
            process_event(e);      
         }
      }

      void attach_graphics_engine(graphics_engine *gfxp)
      {
         gfx = gfxp;
      }

      void attach_game_engine(game_engine *gp)
      {
         g = gp;
      }

      virtual void frame() = 0;

   protected:

      graphics_engine *gfx;
      game_engine *g;

      game *parent;
      queue<engine_event> events_queue;
      virtual void process_event(engine_event&) = 0;
};

#endif
